part of '../index.dart';

class BuildTextInput extends StatefulWidget {
  const BuildTextInput({
    super.key,
    this.controller,
    this.focusNode,
    this.onSendText,
    this.onTapGift,
    this.onTapEmoji,
    this.onTap,
  });

  final TextEditingController? controller;
  final FocusNode? focusNode;
  final VoidCallback? onSendText;
  final VoidCallback? onTapGift;
  final VoidCallback? onTapEmoji;
  final VoidCallback? onTap;

  @override
  State<BuildTextInput> createState() => _BuildTextInputState();
}

class _BuildTextInputState extends State<BuildTextInput> {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
          child: Container(
            decoration: const BoxDecoration(
              color: Color(0xFFF2F2F2),
              borderRadius: BorderRadius.all(Radius.circular(99)),
            ),
            child: Row(
              children: [
                ConstrainedBox(
                  constraints: const BoxConstraints(maxHeight: 40),
                  child: TextField(
                    onTap: widget.onTap,
                    controller: widget.controller,
                    focusNode: widget.focusNode,
                    style: const TextStyle(fontSize: 15),
                    onTapOutside: (event) {},
                    textInputAction: TextInputAction.send,
                    textAlignVertical: TextAlignVertical.center,
                    onSubmitted: (value) {
                      widget.focusNode?.requestFocus();
                      widget.onSendText?.call();
                    },
                    decoration: InputDecoration(
                      hintStyle: const TextStyle(color: Color(0xFFBBBBBB)),
                      hintText: T.current.c_saysomething,
                      fillColor: Colors.transparent,
                      contentPadding:
                          const EdgeInsets.symmetric(horizontal: 13),
                      enabledBorder: const OutlineInputBorder(
                        borderSide:
                            BorderSide(color: Colors.transparent, width: 0),
                        borderRadius: BorderRadius.all(Radius.circular(99)),
                      ),
                      focusedBorder: const OutlineInputBorder(
                        borderSide:
                            BorderSide(color: Colors.transparent, width: 0),
                        borderRadius: BorderRadius.all(Radius.circular(99)),
                      ),
                    ),
                  ),
                ).expanded,
                GestureDetector(
                  onTap: widget.onTapEmoji,
                  behavior: HitTestBehavior.opaque,
                  child: Padding(
                    padding: const EdgeInsets.only(right: 12),
                    child: Image.asset(
                      Images.icChatSmile,
                      width: 40,
                      height: 40,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
        GestureDetector(
          onTap: widget.onTapGift,
          child: Padding(
            padding: const EdgeInsets.only(left: 8, right: 8),
            child: Image.asset(Images.icChatGiftExt, width: 36, height: 36),
          ),
        ),
        GestureDetector(
          onTap: widget.onSendText,
          child: Container(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(99),
              gradient: const LinearGradient(
                colors: [Color(0xFF8A72FE), Color(0xFF6549EC)],
                begin: Alignment.topCenter,
                end: Alignment.bottomCenter,
              ),
            ),
            child: Image.asset(Images.icChatSendExt, width: 40, height: 40),
          ),
        )
      ],
    );
  }
}
